package com.mb.common.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 订单号工具
 *
 * @author michael.li
 * @create 2018-03-30 下午2:17
 **/
public class OrderUtil {
    private static final Logger logger = LoggerFactory.getLogger(OrderUtil.class);


    /**
     * 生成订单号
     * @param type 1:安装;2:维修;3:清洗
     * @return
     */
   public static String genOrderId(String type){
       String orderId = "";
       final IdGenerator idg = IdGenerator.INSTANCE;
       String id = idg.nextId();

       orderId = type + "0" + id;
       return orderId;
   }



    /**
     * 生成支付订单号
     * @param type 1:微信 2:支付宝
     * @return
     */
    public static String genPayOrderId(String type){
        String orderId = "";
        final IdGenerator idg = IdGenerator.INSTANCE;
        String id = idg.nextId();
        orderId = "P" + type + "8"+ id;
        return orderId;
    }


    public static void main(String[] args) {
       for(int i=0;i<100;i++){
            String orderid = genOrderId("1");
            logger.info("orderid :"+orderid);
       }
    }



}
